﻿using Smobiler.Core;
using Smobiler.Core.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FubiManger.Controls
{
    ////ToolboxItem用于控制是否添加自定义控件到工具箱，true添加，false不添加
    //[System.ComponentModel.ToolboxItem(true)]
    partial class dayscontrol : Smobiler.Core.Controls.MobileUserControl
    {
        public dayscontrol() : base()
        {
            //This call is required by the SmobilerUserControl.
            InitializeComponent();
        }
        public bool flag = false;
        public bool flag1 = false;
        /// <summary>
        /// 起始
        /// </summary>
        public string startweek { get; set; }
        /// <summary>
        /// 止
        /// </summary>
        public string endweek { get; set; }
        private void btn0_Press(object sender, EventArgs e)
        {
            Getstartweek((Button)sender);
        }

        private void Getstartweek(Button btn)
        {
            Removecolor();
            flag = true;
            switch (btn.Name)
            {
                case "btn0":
                    startweek = "周日";
                    btn.BackColor = System.Drawing.Color.FromArgb(255, 194, 193);
                    break;
                case "btn1":
                    startweek = "周一";
                    btn.BackColor = System.Drawing.Color.FromArgb(255, 194, 193);
                    break;
                case "btn2":
                    startweek = "周二";
                    btn.BackColor = System.Drawing.Color.FromArgb(255, 194, 193);
                    break;
                case "btn3":
                    startweek = "周三";
                    btn.BackColor = System.Drawing.Color.FromArgb(255, 194, 193);
                    break;
                case "btn4":
                    startweek = "周四";
                    btn.BackColor = System.Drawing.Color.FromArgb(255, 194, 193);
                    break;
                case "btn5":
                    startweek = "周五";
                    btn.BackColor = System.Drawing.Color.FromArgb(255, 194, 193);
                    break;
                case "btn6":
                    startweek = "周六";
                    btn.BackColor = System.Drawing.Color.FromArgb(255, 194, 193);
                    break;
                case "btn7":
                    startweek = "周日";
                    btn.BackColor = System.Drawing.Color.FromArgb(255, 194, 193);
                    break;
            }
        }
        /// <summary>
        /// 终止日期
        /// </summary>
        /// <param name="btn"></param>
        private void GetEndweek(Button btn)
        {
            Removeendcolor();
            flag1 = true;
            switch (btn.Name)
            {
                case "btn_0":
                    endweek = "周日";
                    btn.BackColor = System.Drawing.Color.FromArgb(255, 194, 193);
                    break;
                case "btn_1":
                    endweek = "周一";
                    btn.BackColor = System.Drawing.Color.FromArgb(255, 194, 193);
                    break;
                case "btn_2":
                    endweek = "周二";
                    btn.BackColor = System.Drawing.Color.FromArgb(255, 194, 193);
                    break;
                case "btn_3":
                    endweek = "周三";
                    btn.BackColor = System.Drawing.Color.FromArgb(255, 194, 193);
                    break;
                case "btn_4":
                    endweek = "周四";
                    btn.BackColor = System.Drawing.Color.FromArgb(255, 194, 193);
                    break;
                case "btn_5":
                    endweek = "周五";
                    btn.BackColor = System.Drawing.Color.FromArgb(255, 194, 193);
                    break;
                case "btn_6":
                    endweek = "周六";
                    btn.BackColor = System.Drawing.Color.FromArgb(255, 194, 193);
                    break;
                case "btn_7":
                    endweek = "周日";
                    btn.BackColor = System.Drawing.Color.FromArgb(255, 194, 193);
                    break;
            }
        }
        /// <summary>
        /// 移除起始时间背景
        /// </summary>
        private void Removecolor()
        {
            btn0.BackColor = System.Drawing.Color.FromArgb(238, 238, 238);
            btn1.BackColor = System.Drawing.Color.FromArgb(238, 238, 238);
            btn2.BackColor = System.Drawing.Color.FromArgb(238, 238, 238);
            btn3.BackColor = System.Drawing.Color.FromArgb(238, 238, 238);
            btn4.BackColor = System.Drawing.Color.FromArgb(238, 238, 238);
            btn5.BackColor = System.Drawing.Color.FromArgb(238, 238, 238);
            btn6.BackColor = System.Drawing.Color.FromArgb(238, 238, 238);
        }
        /// <summary>
        /// 移动终止时间背景
        /// </summary>
        private void Removeendcolor()
        {
            btn_0.BackColor = System.Drawing.Color.FromArgb(238, 238, 238);
            btn_1.BackColor = System.Drawing.Color.FromArgb(238, 238, 238);
            btn_2.BackColor = System.Drawing.Color.FromArgb(238, 238, 238);
            btn_3.BackColor = System.Drawing.Color.FromArgb(238, 238, 238);
            btn_4.BackColor = System.Drawing.Color.FromArgb(238, 238, 238);
            btn_5.BackColor = System.Drawing.Color.FromArgb(238, 238, 238);
            btn_6.BackColor = System.Drawing.Color.FromArgb(238, 238, 238);
        }


        private void btn_0_Press(object sender, EventArgs e)
        {
            if (flag == false)
            {
                MessageBox.Show("请选择起始时间");
            }
            else
                GetEndweek((Button)sender);
        }

        private void btnclose_Press(object sender, EventArgs e)
        {
            flag = false;
            this.Close();
        }

        private void btnsave_Press(object sender, EventArgs e)
        {
            flag = true;
            this.Close();
        }
    }
}